package com.gui;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;

import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;

public class ComfirmPassword {
	private byte[] DecodedPVKey;
	public boolean ComfirmPWD(char[] depwd) throws IOException,
			InvalidKeyException, IllegalBlockSizeException,
			NoSuchAlgorithmException, InvalidKeySpecException,
			NoSuchPaddingException, InvalidAlgorithmParameterException {
		byte[] encryptPVkey = null;

		// 개인키를 PVKey file에서 불러옴
		FileInputStream fis = new FileInputStream("PVKey");
		System.out.println("개인키 불러옴");
		MainWindows.setTextLog("개인키 불러옴");
		encryptPVkey = new byte[fis.available()];
		while (fis.read(encryptPVkey) != -1) {
			;
		}
		fis.close();

		PasswrodBasedCrypto pwdcrypt = new PasswrodBasedCrypto();
		DecodedPVKey = pwdcrypt.getDecryptionPVKey(depwd, encryptPVkey);
		if (DecodedPVKey == null) {
			return false;
		} else {
			return true;
		}
	}
	
	public byte[] getDecodedPVKey(){
		return DecodedPVKey;		
	}
}
